#region LicenseHeader

// Copyright 2012 The Trustees of Indiana University.  All rights reserved.
// 
// The Indiana University licenses this file to you under the Apache License, 
// Version 2.0 (the "License"); you may not use this file except in compliance 
// with the License.  You may obtain a copy of the License at 
// 
// http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software 
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
// See the License for the specific language governing permissions and 
// limitations under the License.
// 
// @author Thilina Gunarathne (tgunarat@indiana.edu)

#endregion

#region

using System;
using System.IO;

#endregion

namespace NAligner.Utils
{
    /// <summary>
    ///   Global constants and varilables
    /// </summary>
    public abstract class Commons
    {
        /// <summary>
        ///   Current release version of JAligner
        /// </summary>
        private const string CURRENT_RELEASE = "0.9";

        /// <summary>
        ///   Default home directory
        /// </summary>
        private const string DEFAULT_USER_DIRECTORY = ".";

        /// <summary>
        ///   Default file separator
        /// </summary>
        private const string DEFAULT_FILE_SEPARATOR = "/";

        /// <summary>
        ///   Default line separator
        /// </summary>
        private const string DEFAULT_LINE_SEPARATOR = "\r\n";

        /// <summary>
        ///   User home directory
        /// </summary>
        private static readonly string userDirectory = DEFAULT_USER_DIRECTORY;

        /// <summary>
        ///   Line separator
        /// </summary>
        private static readonly string fileSeparator = DEFAULT_FILE_SEPARATOR;

        /// <summary>
        ///   Line separator
        /// </summary>
        private static readonly string lineSeparator = DEFAULT_LINE_SEPARATOR;

        static Commons()
        {
            {
                try
                {
                    userDirectory = Environment.CurrentDirectory;
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine("Failed getting user current directory: " + e);
                }
            }

            {
                try
                {
                    fileSeparator = Path.DirectorySeparatorChar.ToString();
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine("Failed getting system file separator: " + e);
                }
            }

            {
                try
                {
                    lineSeparator = Environment.NewLine;
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine("Failed getting system line separator: " + e);
                }
            }
        }

        /// <summary>
        ///   Returns system file separator.
        /// </summary>
        /// <returns> file separator </returns>
        public static string FileSeparator
        {
            get { return fileSeparator; }
        }

        /// <summary>
        ///   Returns system line separator.
        /// </summary>
        /// <returns> line separator </returns>
        public static string LineSeparator
        {
            get { return lineSeparator; }
        }

        /// <summary>
        ///   Returns user's current directory.
        /// </summary>
        /// <returns> user's current directory </returns>
        public static string UserDirectory
        {
            get { return userDirectory; }
        }

        /// <summary>
        ///   Returns the current release version of JAligner
        /// </summary>
        public static string CurrentRelease
        {
            get { return CURRENT_RELEASE; }
        }
    }
}